package com.example.administrator.myapplication.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.administrator.myapplication.R;

/**
 * Created by Administrator on 2020/11/26.
 */

public class MyAdapter extends BaseAdapter {
    private Context context;

    public MyAdapter(Context context, String[] citys) {
        this.context = context;
        this.citys = citys;
    }

    private String[] citys;

    @Override
    public int getCount() {
        return citys.length;
    }

    @Override
    public Object getItem(int i) {
        return citys[i];
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view=View.inflate(context, R.layout.select_city_item,null);
        TextView cityNameTv = view.findViewById(R.id.city_name_tv);
        cityNameTv.setText(citys[i]+"");
        return view;
    }
}
